package com.iflytek.ci.qams.dao.impl;

import java.util.List;

import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import com.iflytek.ci.qams.dao.CommentDao;
import com.iflytek.ci.qams.dao.EasyCommentDao;
import com.iflytek.ci.qams.domain.Comment;

/**
 * <p>
 * 快捷回复相关批处理操作DAO.
 * </p>
 * 
 * @author poplar.yfyang
 * @version 1.0 2012-11-18 2:34 PM
 * @since JDK 1.5
 */
@Repository("EasyCommentDao")
public class EasyCommentDaoImpl implements EasyCommentDao {
	/** 注入批处理的SqlSessionTemplate */
	@Qualifier("batchSqlSession")
	@Autowired
	private SqlSessionTemplate batchSqlSession;

	@Override
	public void add_comments(List<Comment> comments) {
		SqlSession sqlSession = batchSqlSession.getSqlSessionFactory()
				.openSession(ExecutorType.BATCH);
	    CommentDao commentDao= sqlSession.getMapper(CommentDao.class);
	    for(Comment comment:comments){
	    	commentDao.addIssue_comment(comment);
	    }
	    sqlSession.flushStatements();
		sqlSession.commit();
		sqlSession.close();
	}

}
